package com.study.controller;

import com.study.entity.Location;
import com.study.entity.Users;
import com.study.repository.LocationRepository;
import com.study.repository.UsersRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Classname HelloContraller
 * @Version 1.0.0
 * @Date 2022/4/2 10:58
 * @Created by yd
 */
@RestController
public class HelloContraller {

	@Autowired
	private LocationRepository locationRepository;

	@Autowired
	private UsersRepository usersRepository;

	@RequestMapping("/hello")
	public List<Location> hello() {
		return locationRepository.findAll();
	}

	@GetMapping("/user")
	public Users users() {
		Users users = new Users().setBirth(LocalDate.now()).setBirthTime(LocalDateTime.now()).setType("哈哈");
		usersRepository.save(users);
		return users;
	}

	@GetMapping("userList")
	public List<Users> listUser() {
		List<Users> all = usersRepository.findAll();
		return all;
	}
}
